package com.controller.teacher;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.model.Mediumterminspection;

public class MediumterminspectionController extends Controller {
	public void save(){
		Mediumterminspection m=getModel(Mediumterminspection.class, "medium");
//		Date d =getParaToDate("medium.medium_guidetime");
//		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
//		String date = dateFormat.format(d); 
//		System.out.println(date);
//		m.set("medium_guidetime",date).save();
		int stuId=getParaToInt("medium.medium_student");
		Record r=Db.findFirst("select medium_id from mediumterminspection where medium_student="+stuId+"");
		System.out.println("r是  "+r);
		
		if(r!=null){
			int id=r.get("medium_id");
			System.out.println("更新操作，检查表id是 "+id);
			m.set("medium_id", id);
			m.update();
		}
		else{
			m.save();
			
		}
		
		render("../pages1/finalT6.jsp");
	}
	public void update(){
		Mediumterminspection m=getModel(Mediumterminspection.class, "medium");
		
	}
}
